<template>
  <div>
    <Spin :spinning="loading" tip="Loading...">
      <FormPanel ref="formPanel" :list="formList" :cols="1" labelWidth="100" :isSubmitBtn="false" />
      <div style="padding-top: 1rem"></div>
      <div
        :style="{
          position: 'absolute',
          left: 0,
          right: 0,
          zIndex: 9,
          borderTop: '1px solid #e9e9e9',
          padding: '10px 20px',
          background: '#fff',
          textAlign: 'right',
        }"
      >
        <multiuse-button type="primary" :click="saveDialog.bind()">保 存</multiuse-button>
        <multiuse-button @click="closeDialog">关 闭</multiuse-button>
      </div>
    </Spin>
  </div>
</template>
<script>
import { updateSettle } from '@/api/claim/factory/SupplierClaimSettle';
import { dictionary } from '@/utils/dictMixin';
import { amountCheck } from '@/utils/validate';
export default {
  mixins: [dictionary],
  props: {
    formData: {
      type: Object,
      default: () => ({}),
    },
  },
  data() {
    return {
      dataList1: [],
      visible: false,
      fetchParams: {}, //ipa 接口
      formList: this.createFormList1(),
      saveData: null,
      val: null,
      loading: false,
    };
  },
  created() {
    this.chuqi();
  },
  methods: {
    async chuqi() {
      this.formList.forEach((x) => {
        x.initialValue = this.formData[x.fieldName];
      });
    },
    async saveDialog() {
      let data = this.$refs.formPanel.SUBMIT_FORM();
        data.id = this.formData.id;
        let res = await updateSettle(data);
        if (res.resultCode === 200) {
          this.$emit('close');
          return this.$notify.success({ title: '提示信息', message: '保存成功' });
        }
    },
    //取消操作
    closeDialog() {
      this.$emit('close', { visible: false, data: this.selectedRows, type: 'close' });
    },
    createFormList1() {
      return [
        {
          type: 'INPUT',
          label: '其他费用',
          placeholder: '请输入',
          fieldName: 'misjudgeAmount',
          initialValue: 0.00,
          rules: [
            { required: true, message: '请选择误判金额', trigger: 'blur' },
            { required: true, validator: amountCheck , trigger: 'blur'}
          ],
          maxlength: 9
        },
        {
          type: 'TEXT_AREA',
          label: '备注',
          fieldName: 'remark',
          rules: [{ required: true, message: '请输入备注', trigger: 'blur' }],
          maxlength: 300,
        },
      ];
    },
  },
};
</script>

<style lang="less" scoped></style>
